package mvp.com.bbc.rcjavaretrofitdaggermvp.presenter;

import javax.inject.Inject;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import mvp.com.bbc.rcjavaretrofitdaggermvp.app.contact.InfoContact;
import mvp.com.bbc.rcjavaretrofitdaggermvp.model.QueryReplyModel;

/**
 * Created by ${cbf} on 2017/12/2.
 */

public class QueryReplyPresenter implements InfoContact.QueryReplyPresenter {
    private InfoContact.QueryReplyModel replyModel;
    private InfoContact.QueryReplyView replyView;
    @Inject
    public QueryReplyPresenter(InfoContact.QueryReplyView replyView) {
        this.replyView = replyView;
        this.replyModel = new QueryReplyModel();
    }


    @Override
    public void queryReplyPresenter(String id) {
        replyModel.queryReplyModel(id)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new Observer<String>() {
                    @Override
                    public void onSubscribe(@NonNull Disposable d) {

                    }

                    @Override
                    public void onNext(@NonNull String s) {
                        replyView.queryReplyView(s);

                    }

                    @Override
                    public void onError(@NonNull Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });

    }
}
